<%@ include file="../views/taglib.jsp" %>

<!DOCTYPE>
<html>
	<head>
		<jsp:include page="../views/resources.jsp" />
		<title><tiles:getAsString name="title" /></title>
	</head>
	<body>
	<tilesx:useAttribute name="current"/>
		<!-- Static navbar -->
    <div class="navbar navbar-default navbar-static-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="<c:url value="/" />" id="top">Final Project</a>
        </div>
        <div class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
            <li class="${current == 'index' ? 'active' : ''}"><a href="<c:url value="/" />" >Home</a></li>
            <security:authorize access="isAuthenticated()">
            <li class="${current == 'profile' ? 'active' : ''}"><a href="<c:url value="/profile"/>">Profile</a></li>
            </security:authorize>
            <security:authorize access="!isAuthenticated()">
            <li class="${current == 'login' ? 'active' : ''}"><a href="<c:url value="/login"/>">Login</a></li>
            </security:authorize>
            <security:authorize access="hasAnyRole('ROLE_ADMIN', 'ROLE_SUPPORT')"  >
            <li class="${current == 'create' ? 'active' : ''}"><a href="<c:url value="/create"/>">Create</a></li>
            </security:authorize> 
            <security:authorize access="hasRole('ROLE_SUPPORT')">
            <li class="${current == 'update' ? 'active' : ''}"><a href="<c:url value="/updateinfo"/>">Update Information</a></li>
            </security:authorize> 
            <security:authorize access="hasRole('ROLE_ADMIN')">
            <li class="${current == 'changestatus' ? 'active' : ''}"><a href="<c:url value="/changestatus"/>">Change Status</a></li>
            </security:authorize>
            <security:authorize access="hasAnyRole('ROLE_ADMIN', 'ROLE_SUPPORT')">
            <li class="${current == 'history' ? 'active' : ''}"><a href="<c:url value="/history"/>">History User</a></li>
            </security:authorize>
          </ul>
          <ul class="nav navbar-nav navbar-right">
	          <security:authorize access=" isAuthenticated()">
	          	<li><a>Welcome ${pageContext.request.userPrincipal.name}</a></li>
	          	<li><a><img src="data:image/jpeg;base64,${avatar}" class="img-circle" width="25" height="25"></a><li>
	          	<li><a href="<c:url value="/logout"/>">Logout</a></li>
	          </security:authorize>
          </ul>
        </div><!--/.nav-collapse -->
      </div>
    </div>
    
   	<div class="container">
		<tiles:insertAttribute name="body"/>
	</div>	
	
	<div class="container" style="padding-top: 50px;">
		<tiles:insertAttribute name="footer" />
	</div>
	</body>
</html>